//
//  DXWLoginRegisterViewController.m
//  BuDeJie
//
//  Created by 淡馨慰 on 16/8/4.
//  Copyright © 2016年 淡馨慰. All rights reserved.
//

#import "DXWLoginRegisterViewController.h"
#import "DXWLoginRegisterView.h"
#import "DXWFastLoginView.h"

@interface DXWLoginRegisterViewController ()

@property (weak, nonatomic) IBOutlet UIButton *loginRegisterBtn;

@property (weak, nonatomic) IBOutlet UIView *middleView;

@property (weak, nonatomic) IBOutlet UIView *bottomView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *middleView_LeftConstraint;

@end

@implementation DXWLoginRegisterViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //1.创建登录view
    UIView *loginView = [DXWLoginRegisterView loginView];
    [_middleView addSubview:loginView];
    
    //2.创建注册view
    UIView *registerView = [DXWLoginRegisterView registerView];
    [_middleView addSubview:registerView];
    
    //3.创建快速登录view
    UIView *fastLoginView = [DXWFastLoginView fastLoginView];
    [_bottomView addSubview:fastLoginView];
    
//    UITextField *text = [[UITextField alloc]init];
    
    
}
-(void)viewDidLayoutSubviews
{
    UIView *loginView = _middleView.subviews[0];
    loginView.frame = CGRectMake(0, 0, screenW, self.middleView.dxw_height);
    
    //将middleView变宽成屏幕2倍,好存放注册view
    UIView *registerView = _middleView.subviews[1];
    registerView.frame = CGRectMake(screenW, 0, screenW, self.middleView.dxw_height);
    
    UIView *fastLoginView = _bottomView.subviews[0];
    fastLoginView.frame = _bottomView.bounds;
    [super viewDidLayoutSubviews];
}
- (IBAction)loginOrRegisterClick:(id)sender
{
    self.loginRegisterBtn.selected = !self.loginRegisterBtn.selected;
    
    //技巧:三目运算
    //判断约束的值是否为0,为0,则左移,不为0则右移变成0;
    _middleView_LeftConstraint.constant =(_middleView_LeftConstraint.constant == 0)? -screenW : 0;
    [UIView animateWithDuration:0.25 animations:^{
        //重新布局子控件view
        [self.view layoutIfNeeded];
    }];
    
}

- (IBAction)closeBtnClick:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:^{
        NSLog(@"点击关闭了登入/注册界面");
    }];
}








@end

